package com.gack.helper.common.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class ChangeDateTimeUtil {
	
	public static String zExchangeUTC(String datetime) throws Exception {
		datetime = datetime.replace("Z", " UTC");// 注意是空格+UTC
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");// 注意格式化的表达式
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date1 = null;
		date1 = format.parse(datetime);
		String str  = sdf.format(date1);
		return str;
	}
	
	/**
	 * 
	 * @param datetime 传入日期时间
	 * @param day 需要增加的天数
	 * @return
	 */
	public static String zExchangeUTCAndAddDay(String datetime, int day) throws Exception {
		datetime = datetime.replace("Z", " UTC");// 注意是空格+UTC
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");// 注意格式化的表达式
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date1 = null;
		date1 = format.parse(datetime);
		Calendar calendar1 = Calendar.getInstance();
		calendar1.setTime(date1);
		calendar1.add(Calendar.DAY_OF_MONTH, 1);
		String str  = sdf.format(calendar1.getTime());
		return str;
	}

}
